package com.company.management.service.impl;

import com.company.management.dto.UserDto;
import com.company.management.mapper.UserMapper;
import com.company.management.modal.entity.User;
import com.company.management.service.UserService;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserServiceImpl implements UserService {
    private final UserMapper userMapper;

    public UserServiceImpl(UserMapper userMapper) {
        this.userMapper = userMapper;
    }

    @Override
    public int save(User user) {
        return userMapper.save(user);
    }

    public  int update(User user){
        return userMapper.update(user);
    }
    @Override
    public UserDto findUserByUserName(String userName) {
        return userMapper.findUserByUserName(userName);
    }

    @Override
    public UserDto findUserByUserNameAndPwd(String userName, String password) {
        return userMapper.findUserByUserNameAndPwd(userName, password);
    }



    @Override
    public UserDto findUserById(Integer userId) {
        return userMapper.getByUserId(userId);
    }

    @Override
    public UserDto findUserByToken(String token) {
        return userMapper.getByToken(token);
    }

    @Override
    public List<UserDto> listAll() {
        return userMapper.listAll();
    }

    @Override
    public int batchUpdateUsers(List<User> users) {
        return userMapper.batchUpdateUsers(users);
    }
}
